﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace qf_cms.admin
{
	public partial class _default : System.Web.UI.Page
	{
		protected string tip = "";

		protected void Page_Load(object sender, EventArgs e)
		{
			if (IsPostBack)
			{
				//校验码
				if ( string.IsNullOrEmpty( Request.Form["VerifyCode"] ))
					Response.End();

				if (Session["VerifyCode"] == null)
				{
					tip = "校验码失效,请刷新页面!";
					return;
				}

				if (string.Compare(Session["VerifyCode"].ToString(), Request.Form["VerifyCode"].Trim(), true) != 0)
				{
					tip = "校验码错误!";
					return;
				}

				if ( string.IsNullOrEmpty( Request.Form["UserName"] ))
					Response.End();

				LogicLayer mgr = new LogicLayer();
				int i = mgr.Logon(Request.Form["UserName"], Request.Form["UserPwd"], this.Context);
				if (i == 0)
					Response.Redirect("home.aspx");
				else if (i == 2)
					tip = "License验证失败!";
				else
					tip = "登录失败!";
				
			}
		}
	}
}